<?php

//getting the cart id from the cookie
$shoppingcart_id = $_COOKIE["shoppingcart_id"];

//we will use the REL table to extract the items inside this specific shopping cart
$items = mysql_query("SELECT ID_ITEM, AMOUNT FROM rel WHERE ID_CART = '$shoppingcart_id'");

//we now have a set of information containing the ids of the items
//by using the ids of the items, we will extract the information related to every item

echo("Content of your shopping cart:<br><br>");

while($item = mysql_fetch_array($items))
	{
	//find out the id of the item stored into the shopping cart
	$item_id = $item["ID_ITEM"];
	$nr_of_items = $item["AMOUNT"];
	
	//extract from DB the information related to the item
	$itemdetails = mysql_query("SELECT NAME, PRICE, DESCRIPTION FROM items WHERE id = '$item_id'");
	$itemfinal = mysql_fetch_array($itemdetails);
	
	//print the information to screen
	echo("Item name: ".$itemfinal["NAME"]."<br>");
	echo("Item price: ".$itemfinal["PRICE"]."<br>");
	echo("Item description: ".$itemfinal["DESCRIPTION"]."<br>");
	echo("Item amount: ".$nr_of_items."<br><br><hr>");
	}

?>